function BigNumber(num, size) {
    this.size = size || 1000;
    this.pool = [];
    var tmp=num, tmp1;
    do {
        tmp1 = tmp%this.size;
        this.pool.push(tmp1);
        tmp = (tmp-tmp1)/this.size;
    } while(tmp>0);
}

BigNumber.prototype.time = function(a) {
    
    var tmp = 0, tmp1;
    for(var i=0; i<this.pool.length; i++) {
        var p = this.pool[i]*a + tmp;
        var tmp = p%this.size;
        this.pool[i] = tmp;
        tmp = (p-tmp)/this.size;
    }
    if(tmp) {
        do {
            tmp1 = tmp%this.size;
            this.pool.push(tmp1);
            tmp = (tmp-tmp1)/this.size;
        } while(tmp>0);    
    }
};

BigNumber.prototype.add = function(a) {
    if(typeof(a)=="number") a = new BigNumber(a);
    var tmp=0, tmp1;
    for(var i=0; i<a.pool.length; i++) {
        var p = (this.pool[i]||0) + a.pool[i] + tmp;
        var tmp = p%this.size;
        this.pool[i] = tmp;
        tmp = (p-tmp)/this.size;
    }
    if(tmp) {
        do {
            tmp1 = tmp%this.size;
            this.pool.push(tmp1);
            tmp = (tmp-tmp1)/this.size;
        } while(tmp>0);    
    }  
    return this;  
};

BigNumber.prototype.countDigital = function() {
    var sum=0;
    sum = this.pool.length*3;
    var tmp=this.pool[this.pool.length-1];
    if(tmp<10) return sum-2;
    if(tmp<100) return sum-1;
    return sum;
}

BigNumber.prototype.sumDigital = function() {
    var sum=0;
    for(var i=0; i<this.pool.length; i++) {
        var tmp=this.pool[i];
        do {
            tmp1 = tmp%10;
            sum += tmp1;
            tmp = (tmp-tmp1)/10;
        }while(tmp>0);
    }
    return sum;
}

BigNumber.prototype.toString = function() {
    return this.pool.reverse().join("");
}


var numerator=new BigNumber(3), denominator=new BigNumber(2), count=0;
for(var i=2; i<=1000; i++) {
    var a1=numerator;
    var b1=denominator;
    var a2=new BigNumber(0);
    var b2=new BigNumber(0);
    a2.add(a1).add(b1).add(b1);
    b2.add(a1).add(b1);
    numerator=a2;
    denominator=b2;
    print(a2.countDigital() + "/" + b2.countDigital());
    if(a2.countDigital() > b2.countDigital()) count++;
    //print(i + ".." + a2+"/"+b2);
};



print("count=" + count);

